package com.cxy.controller;

import com.cxy.pojo.User;
import com.cxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 蔡心勇
 * @create 2022/4/2 - 15:41
 */
@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public ModelAndView login(String username,String password){
        ModelAndView modelAndView=new ModelAndView();
        User user = userService.queryUser(username, password);
        if (user==null){
            modelAndView.addObject("msg","fail");
        }else{
            modelAndView.addObject("msg","success");
        }
        modelAndView.setViewName("show");

        return modelAndView;
    }
}
